import axios from 'axios'; 
import type {
  Result,
} from './typings';

/**
 * 统计评论数量 GET /api/comment/countComment
 */
export async function get_api_comment_countComment (
  options?: Record<string, any>,
): Promise<Result<any>> {
  return axios({
    method: 'GET',
    url: `/api/comment/countComment`,
    ...(options || {}),
  })
}

/**
 * 删除评论 POST /api/comment/delete
 */
export async function post_api_comment_delete (
  params: {
    /** 评论数据 */
    id?: number;
  },
  options?: Record<string, any>,
): Promise<Result<any>> {
  return axios({
    method: 'POST',
    url: `/api/comment/delete`,
    params: {
      ...params,
    },
    ...(options || {}),
  })
}

/**
 * 后台查询最新评论 GET /api/comment/getNewComment
 */
export async function get_api_comment_getNewComment (
  options?: Record<string, any>,
): Promise<Result<any>> {
  return axios({
    method: 'GET',
    url: `/api/comment/getNewComment`,
    ...(options || {}),
  })
}

/**
 * 发布评论 POST /api/comment/insert
 */
export async function post_api_comment_insert (
  data: {
    /** 评论关联的文章id */
    articleId?: number;
    /** 评论作者名 */
    author?: string;
    /** 评论内容 */
    content?: string;
    /** 创建时间 */
    createTime?: string;
    /** 评论id */
    id?: number;
    /** 评论用户所在ip */
    ip?: string;
    /** 评论状态 */
    status?: string;
  },
  options?: Record<string, any>,
): Promise<Result<any>> {
  return axios({
    method: 'POST',
    url: `/api/comment/insert`,
    data: {
      ...data,
    },
    ...(options || {}),
  })
}

/**
 * 分页展示文章评论 POST /api/comment/list
 */
export async function post_api_comment_list (
  data: {
    /** 点击的文章id */
    articleId?: number;
    /** 当前页数 */
    pageNum?: number;
    /** 每页行数 */
    pageSize?: number;
  },
  options?: Record<string, any>,
): Promise<Result<any>> {
  return axios({
    method: 'POST',
    url: `/api/comment/list`,
    data: {
      ...data,
    },
    ...(options || {}),
  })
}
